#include <iostream>
#include <string>
#include <algorithm>
using std::endl;
using std::cin;
using std::cout;
using std::string;
class Parser{
public:
    static string lookahead;
    Parser(){
        cin >> lookahead;
    }
    void expr(){
        term();
        while(1){
            if(lookahead == "+"){
                match("+");term();cout<<"+ ";
            }
            else if(lookahead == "-"){
                match("-");term();cout<<"- ";
            }
            else {
                cout<<endl;
                return ;
            }
        }
    }
    //识别一个中缀表达式，并打印后缀表达式
    void term(){
        if(Isdigit(lookahead)){
            cout << lookahead+" ";match(lookahead);
        }
        else throw("syntax error");    
    }
    //接受 t ，也可以输入lookahead，功能为读入下一个词
    void match(const string& t){
        if(lookahead == t){
            cin>>lookahead;
        }
        else throw("syntax error");
    }
    bool Isdigit(const string& in){
        if(in!="+"&&in!="-"&&in!="*"&&in!="/")return true;
        else return false;
    }
};
string Parser::lookahead = "";